<%--
  Created by IntelliJ IDEA.
  User: 10630
  Date: 2023/8/23
  Time: 14:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" isELIgnored="false" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <!-- 指定字符集 -->
    <meta charset="utf-8">
    <!-- 使用Edge最新的浏览器的渲染方式 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- viewport视口：网页可以根据设置的宽度自动进行适配，在浏览器的内部虚拟一个容器，容器的宽度与设备的宽度相同。
    width: 默认宽度与设备的宽度相同
    initial-scale: 初始的缩放比，为1:1 -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>部门管理信息管理系统</title>

    <!-- 1. 导入CSS的全局样式 -->
    <link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
    <!-- 2. jQuery导入，建议使用1.9以上的版本 -->
    <script src="${pageContext.request.contextPath}/js/jquery-2.1.0.min.js"></script>
    <!-- 3. 导入bootstrap的js文件 -->
    <script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
    <style type="text/css">
        td, th {
            text-align: center;
        }
    </style>
</head>
<body>
<div class="container">


    <h3 style="text-align: center">部门信息列表</h3>
    <form action="${pageContext.request.contextPath}/findByNA" method="post">
    <div>
        <label>部门：</label>
        <input type="text" name="name" value="${name}" placeholder="请输入部门"/>
        <label>地址：</label>
        <input type="text" name="address" value="${address}" placeholder="请输入地址"/>
        <input class="btn btn btn-primary" type="submit" value="搜索">
    </div>
    </form>

<%--    <form class="form-inline">
        部门名称：
        <div class="form-group mx-sm-3 mb-2">
            <label for="name" class="sr-only">部门名称</label>
            <input type="text" class="form-control" id="name" >
        </div>
        <button type="submit" class="btn btn-primary mb-2">搜索</button>
    </form>--%>

    <table border="1" class="table table-bordered table-hover">
        <tr class="success">
            <th>序号</th>
            <th>部门编号</th>
            <th>部门名称</th>
            <th>部门地址</th>
            <th>操作</th>

        </tr>

        <c:forEach varStatus="index" var="item" items="${deptList}">
            <tr>
                <td>${index.index+1}</td>
                <td>${item.id}</td>
                <td>${item.name}</td>
                <td>${item.address}</td>
                <td><a class="btn btn-default btn-sm" href="${pageContext.request.contextPath}/deptUpdatePage?id=${item.id}">修改</a>&nbsp;
                <a class="btn btn-default btn-sm" href="${pageContext.request.contextPath}/deptDelete?id=${item.id}">删除</a></td>
            </tr>
        </c:forEach>

        <%-- 所有请求都要经过servlet --%>
        <tr>

            <td colspan="5" align="center"  >
                <a class="btn btn-default btn-sm" href="${pageContext.request.contextPath}/deptList?page=1">首页</a>&nbsp;
                <a class="btn btn-default btn-sm" href="${pageContext.request.contextPath}/deptList?page=${page-1}">上一页</a>&nbsp;
                <a class="btn btn-default btn-sm" href="${pageContext.request.contextPath}/deptList?page=${page+1}">下一页</a>&nbsp;
                <a class="btn btn-default btn-sm" href="${pageContext.request.contextPath}/deptList?page=${totalPage}">尾页</a>&nbsp;
            </td>
        </tr>
        <tr>
            <td colspan="5" align="center"><a class="btn btn-primary" href="${pageContext.request.contextPath}/deptAddPage">添加</a></td>
        </tr>
    </table>
    <c:if test="${not empty msg}">
        <div class="alert alert-warning alert-dismissible" role="alert">
            <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <strong>错误!</strong> ${msg}
        </div>
    </c:if>
</div>
</body>
</html>
